<div style="float: left;margin-top: 50px;">
<div class="hd">
    <h3>行业</h3>

    <div class="dashed"></div>
</div>
<dd>
    <div class="tt" style="float: left">当前所在行业：</div>

    <select id="work" onchange="changework()">

        <volist name="work" id="v">
            <option name="{$v}"
            <if condition="$v eq $profession">selected="selected"</if>
            >{$v}</option>
        </volist>
    </select><span id="showprofession"></span>
    <input type="text" disabled="true" id="change">
</dd>


<div class="clearfix"></div>
<div style="margin-top: 30px;"></div>
<div class="hd">
    <h3>公司</h3>

    <div class="dashed"></div>
</div>
<div class="bd">
    <ul class=" js_left_list" id="group_list">
        <volist name="career" id="vo">
            <li rel="-2" id="group__2" class="grouplist1" style="float: left">
                <div style="width: 700px;margin-top: 10px;">
                    <div style="float: left;">
                        <div class="txt_schoolname">{$vo.company} {$vo.starttime} --{$vo.endtime}</div>
                    </div>
                    <div style="float: right">
                        <a id="edit{$vo.id}" onclick="mshowedit('{$vo.id}')" class="act-edit a "
                           style=" ">编辑</a>
                        <a id="del{$vo.id}" onclick="delcompany('{$vo.id}')" class="act-edit a "
                           style=" ">删除</a>
                    </div>


                </div>

            </li>
        </volist>
    </ul>
</div>
<div class="clearfix"></div>
<div style="margin-top: 20px;float: left;width: 300px;">

    <div onclick="mshowdiv()" id="creat_company" class="btn_creat placeholder"><span class="xpy-icon je-ico-add"></span>添加工作经历
    </div>
    <div style="background: #f2f6f9; width: 600px;">


        <div class="group-action group-edit" id="creat_company_div"
             style="display: none;width: 700px;padding: 20px 12px 50px 75px;">


            <div style="">
                <div class="clearfix"></div>
                <div class="kong">
                    <div class="tt" style="float: left">公司名称：</div>
                    <div>
                        <input name="ccompanyname" id="ccompanyname" autocomplete="off" type="text" value=""/></div>
                </div>
                <div class="clearfix"></div>
                <div class="kong">

                    <div class="tt">在职时间： <input name="p" onchange="timechange()" id="p1" class="" value="1"
                                                 type="checkbox"><label class="p" for="p1">正在这里工作</label>
                    </div>

                    <div style="float: left;margin-top: 10px;">
                        <select name="year" id="cyear">
                            <option name="0">年</option>
                            <volist name="year" id="v2">
                                <option name="{$v2}">{$v2}</option>
                            </volist>
                        </select>
                        <select name="month" id="cmonth">
                            <option name="0">月</option>
                            <volist name="month" id="v3">
                                <option name="{$v3}">{$v3}</option>
                            </volist>
                        </select>--
                    </div>

                    <input type="text" disabled="true" value="现在" id="now" style="display: none;margin-top: 10px;">

                    <div id="endtime" style="float: left;margin-top: 10px;">
                        <select name="year" id="ceyear">
                            <option name="0">年</option>
                            <volist name="year" id="v4">
                                <option name="{$v4}">{$v4}</option>
                            </volist>
                        </select>
                        <select name="month" id="cemonth">
                            <option name="0">月</option>
                            <volist name="month" id="v5">
                                <option name="{$v5}">{$v5}</option>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="kong">
                    <div class="tt" style="float: left"> 个人简介：</div>
                    <div class="form-row">
                        <textarea id="ccontent" class="s-textarea" name="content"></textarea>
                    </div>
                </div>
            </div>
            <p class="act" style="margin-top: 10px;">
                <input onclick="add_company()" class="btn_add" type="submit" value="添加"/>
                <input onclick="mhidediv()" class="btn_add" type="submit" value="取消"/>


            </p>
        </div>


        <volist name="career" id="vo">
            <div class="group-action group-edit"  id="edit_company_div{$vo.id}" style="display: none;width: 700px;padding: 20px 12px 50px 75px;">
                <div style="">
                    <div class="clearfix"></div>
                    <div class="kong">
                        <div class="tt" style="float: left">公司名称：</div>
                        <div>  <input name="companyname" id="companyname" autocomplete="off" type="text" value="{$vo.company}"/></div>
                    </div>
                    <div class="clearfix"></div>

                    <div class="kong">
                        <div class="tt">在职时间：<input name="p" onchange="timechange2('{$vo.id}')" id="p2{$vo.id}" class=""                                          value="1" type="checkbox"
                            <if condition="1 eq $vo['tig']">checked</if>
                            ><label class="p" for="p1">正在这里工作</label></div>
                        <div style="float: left;margin-top: 10px;">
                            <select name="year" id="year">
                                <option name="0">年</option>
                                <volist name="year" id="v2">
                                    <option name="{$v2}"
                                    <if condition="$v2 eq $vo['start']['0']">selected="selected"</if>
                                    >{$v2}</option>
                                </volist>
                            </select>
                            <select name="month" id="month">
                                <option name="0">月</option>
                                <volist name="month" id="v3">
                                    <option name="{$v3}"
                                    <if condition="$v3 eq $vo['start']['1']">selected="selected"</if>
                                    >{$v3}</option>
                                </volist>
                            </select>--
                        </div>
                        <input class="none" type="text" disabled="true" value="现在" id="now{$vo.id}"
                        <if condition="1 eq $vo['tig']"> style="display: block;margin-top: 10px;"
                            <else/>
                            style="display: none;margin-top: 10px;"
                        </if>>
                        <div id="endtime{$vo.id}" style='float: left;margin-top: 10px;<if condition=" 1 eq $vo['tig']">display: none; <else/> display: block;</if> '>
                        <select name="year" id="eyear">
                            <option name="0">年</option>
                            <volist name="year" id="v4">
                                <option name="{$v4}"
                                <if condition="$v4 eq $vo['end']['0']">selected="selected"</if>
                                >{$v4}</option>
                            </volist>
                        </select>
                        <select name="month" id="emonth">
                            <option name="0">月</option>
                            <volist name="month" id="v5">
                                <option name="{$v5}"
                                <if condition="$v5 eq $vo['end']['1']">selected="selected"</if>
                                >{$v5}</option>
                            </volist>
                        </select>
                        </div>
                        </div>


                    <div class="clearfix"></div>
                    <div class="kong">
                        <div class="tt" style="float: left"> 个人简介：</div>
                        <div class="form-row">
                            <textarea id="content" class="s-textarea" name="content">{$vo.content}</textarea>
                        </div>
                    </div>
                </div>
            <p class="act" style="margin-top: 10px;" >

                <input onclick="edit_company('{$vo.id}')" class="btn_add" type="submit" value="保存"/>
                <input onclick="mhideeditdiv('{$vo.id}')" class="btn_add" type="submit" value="取消"/>


                </p>
            </div>
        </volist>

    </div>
</div>

<script>
    function edit(gid) {
        $(".grouplist1 .act-edit").hide();
        $(".group-edit").hide();
        document.getElementById('edit' + gid).style.display = " block";
    }
    function mshowdiv() {
        document.getElementById("creat_company_div").style.display = " block";
        document.getElementById("creat_company").style.display = " none";
    }
    function mhidediv() {
        document.getElementById("creat_company_div").style.display = " none";
        document.getElementById("creat_company").style.display = " block";
    }
    function mhideeditdiv(id) {
        document.getElementById("edit_company_div" + id).style.display = " none";
        document.getElementById("creat_company").style.display = " block";
    }

    function mshowedit(id) {
        document.getElementById("edit_company_div" + id).style.display = " block";
        document.getElementById("creat_company").style.display = " none";
        document.getElementById("creat_company_div").style.display = " none";

    }
    function edit_company(id) {

        $.post(U("friend/Info/editcompany"), { id: id, company: $('#companyname').val(), syear: $("#year").val(), smonth: $("#month").val(), eyear: $("#eyear").val(), emonth: $("#emonth").val(), isnow: $("#p2:checked").val(), content: $("#content").val()}, function (data) {
            if (data.status == 1) {
                ui.success('修改成功！')
            }
            $('#work_list').load(U("friend/Info/_work"));

        }, 'json');
    }
    function add_company() {
        alert($("#p1:checked").val());
        $.post(U("friend/Info/addcompany"), {company: $('#ccompanyname').val(), syear: $("#cyear").val(), smonth: $("#cmonth").val(), eyear: $("#ceyear").val(), emonth: $("#cemonth").val(), isnow: $("#p1:checked").val(), content: $("#ccontent").val()}, function (data) {
            if (data.status == 1) {
                ui.success('添加成功！')
            }
            $('#work_list').load(U("friend/Info/_work"));

        }, 'json');
    }
    function delcompany(id) {
        $.post(U("friend/Info/delcompany"), { id: id}, function (data) {
            if (data.status == 1) {
                ui.success('删除成功！')
            }
            location.reload()
        }, 'json');
    }
    function changework() {

        $.post(U("friend/Info/changeprofession"), { profession: $("#work").val()}, function (data) {
            if (data.status == 1) {
                $('#change').val('已修改');
                setTimeout("hide()", 3000);
            }

        }, 'json');


    }
    function hide() {
        $('#change').val('');
    }
    function timechange() {
        if ($("#p1:checked").val() == 1) {
            document.getElementById("endtime").style.display = " none";
            document.getElementById("now").style.display = " block";
        }
        else {
            document.getElementById("now").style.display = " none";
            document.getElementById("endtime").style.display = " block";
        }

    }

    function timechange2(id) {
        if ($("#p2" + id + ":checked").val() == 1) {
            document.getElementById("endtime" + id).style.display = " none";
            document.getElementById("now" + id).style.display = " block";
        }
        else {
            document.getElementById("now" + id).style.display = " none";
            document.getElementById("endtime" + id).style.display = " block";
        }

    }
</script>
